import {Injectable} from "@angular/core";
import {
  ActionSheetController,
  AlertController,
  LoadingController,
  MenuController,
  ModalController

} from "ionic-angular";
import {CustomerProvider} from "../../providers/customerProvider";
import {CartProvider} from "../../providers/cartProvider";
import {EmployeeProvider} from "../../providers/employeeProvider";
import {url_store} from "../../config";
import {Http} from "@angular/http";

@Injectable()
export class KitProvider {
  public auth: CustomerProvider | EmployeeProvider;

  constructor(public menu: MenuController,
              public alert: AlertController,
              public http: Http,
              public loading: LoadingController,
              public actionSheet: ActionSheetController,
              public modal: ModalController,
              public customer: CustomerProvider,
              public employee: EmployeeProvider,
              public cart: CartProvider) {
    if (this.employee.check())
      this.auth = this.employee;
    else
      this.auth = this.customer;
  }


  public alertMsg(title: string, subTitle: string, buttons?): any {
    let alert = this.alert.create({
      title: title,
      subTitle: subTitle,
      buttons: buttons ? buttons : ['OK']
    });
    alert.present();
    return alert;
  }

  loadingPresent(): any {
    let loading = this.loading.create({content: 'Please wait...'});
    loading.present();
    return loading;
  }

  getTables() {
    return this.http.get(url_store)
      .map(res => res.json().data)
  }
}
